<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiSiteRouterTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_site_router';

    /**
     * Run the migrations.
     * @table qii_site_router
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->comment('ID');
            $table->string('target_key', 20)->default('')->comment('源key');
            $table->unsignedInteger('target_id')->default('0')->comment('源ID(设置此路由的数据ID,例如文章ID)');
            $table->string('router', 180)->default('')->comment('路由');
            $table->string('path', 180)->default('')->comment('系统路径');

            $table->index(["path"], 'path');

            $table->index(["target_key"], 'target');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
